7 vector
<int> partiendo( int x
, int y
, vector
<int> a
);
8 vector
<int> deformar( int i
, int h
, int j
, vector
<int> a
);
12 int n
, x
, y
, h
, cont
=0;
13 while( scanf("%d",&n
) && n
!=0 ){
18 while(h
--){ cin
>> num
; parts
.push_back(num
); }
19 parts
=partiendo( x
, y
, parts
);
20 if( parts
.size()==0 && cortes
-1<n
) cout
<< "Case " << cont
<< ": Yes" << endl
;
21 else cout
<< "Case " << cont
<< ": No" << endl
;
26 vector
<int> partiendo( int x
, int y
, vector
<int> a
){
28 if( a
.size() == 0 ) return a
;
29 for( int i
=0; i
< a
.size() ; i
++ ){
32 for( int h
=i
; h
< a
.size() ; h
++ ){
34 else if( a
[i
]==a
[h
] ) b
+=a
[h
];
35 if( b
%x
==0 && y
-(b
/x
)>-1 ){ cortes
+=(h
-i
)+1; return partiendo( x
, y
-(b
/x
), deformar(i
,h
,-5,a
) ); }
36 if( b
%y
==0 && x
-(b
/y
)>-1 ){ cortes
+=(h
-i
)+1; return partiendo( x
-(b
/y
), y
, deformar(i
,h
,-5,a
) ); }
38 for( int j
=h
+1; j
< a
.size() ; j
++ ){
41 if( a
[i
]==a
[j
] ) s
=b
+a
[j
];
42 if( s
%x
==0 && y
-(s
/x
)>-1 ){ cortes
+=(h
-i
)+2; return partiendo( x
, y
-(s
/x
), deformar(i
,h
,j
,a
) ); }
43 if( s
%y
==0 && x
-(s
/y
)>-1 ){ cortes
+=(h
-i
)+2; return partiendo( x
-(s
/y
), y
, deformar(i
,h
,j
,a
) ); }
53 vector
<int> deformar( int i
, int h
, int j
, vector
<int> a
){
55 for( int g
=0; g
<a
.size(); g
++ ) if( g
<i
|| g
>h
&& g
!=j
) f
.push_back(a
[g
]);